cmake_minimum_required(VERSION 3.19)

# env
if (CMAKE_HOST_SYSTEM_NAME MATCHES "Linux")
    # linux
    set(PICO_SDK_PATH /media/tacom/fd1834d9-91ec-45dc-908b-eed1b326caaa/Envs/pico-sdk)
    set(PICO_TOOLCHAIN_PATH /media/tacom/fd1834d9-91ec-45dc-908b-eed1b326caaa/Envs/gcc-arm-10)
else()
    # windows
    set(PICO_SDK_PATH D:/Development/Envs/pico-sdk)
    set(PICO_TOOLCHAIN_PATH D:/Development/Envs/gcc-arm-none-eabi-10)
    set(Python3_EXECUTABLE D:/Development/Envs/anaconda3/envs/pico-dev/python.exe)
endif()

set(PICO_BOARD pico)
set(PICO_PLATFORM rp2040)

include(pico_sdk_import.cmake)

# project start
project(pico-device-slave)

# init pico
pico_sdk_init()

# compile
add_executable(${PROJECT_NAME}
        main.cpp
        usb/dev_lowlevel.c usb/dev_lowlevel.h
        spi/spi_transfer.c spi/spi_transfer.h
        io_tools/io_helper.c io_tools/io_helper.h)

target_link_libraries(${PROJECT_NAME}
    PRIVATE
        pico_stdlib
        hardware_resets
        hardware_irq
        hardware_spi
        hardware_dma
)

target_include_directories(${PROJECT_NAME}
    PRIVATE
        .
        usb
        spi
        led
        io_tools
)

# use usb to output serial
#pico_enable_stdio_usb(${PROJECT_NAME} 1)
#pico_enable_stdio_uart(${PROJECT_NAME} 0)

# output to elf
pico_add_extra_outputs(${PROJECT_NAME})